#!/usr/bin/env python
#encoding=utf8
"""
@描述：模拟hadoop的mapper执行,求top 2
@日期：2015年02月03日 星期二

@作者：hongxingfan
"""

import sys

mapPv = dict()


if __name__ == "__main__":
	for line in sys.stdin:
		line = line.strip()
		cols = line.split("\t")
		key = ":".join(cols[:2])
		value = int(cols[2])
		# 写程序要简洁
		if(key not in mapPv):
			mapPv[key] = value
		else:
			mapPv[key] += value

	# 输出
	for (k,v) in sorted(mapPv.iteritems(),key = lambda x:x[1], reverse = True):
		sys.stdout.write(k + "\t" + str(v) + "\n")
		sys.stdout.flush()
